{
module Language.Coal.Lexer (lexer,Token(..)) where
}

%wrapper "basic"

$digit = 0-9			-- digits
$alpha = [a-zA-Z]		-- alphabetic characters
tokens :-
	[\n] 					{const Newline}
	$white					;
	"+"					{const Plus}
	"-"					{const Minus}
	"*"					{const Times}
	"/"					{const Divide}
	"%"					{const Rem}
	"="					{const Asign}
	"("					{const OpenParenth}
	")"                                     {const CloseParenth}
	"=="                                    {const Equal}
	"!="                                    {const NotEqual}
	"<"                                     {const Less}
	">"                                     {const Greater}
	"<="                                    {const LessEqual}
	">="                                    {const GreaterEqual}
	";"                                     {const Semicolon}
	":"                                     {const Colon}
	","                                     {const Coma}
	"if"					{const If}
	"then"					{const Then}
	"while"					{const While}
	"do"					{const Do}
	"end"					{const End}
	"var"					{const Var}
	"def"					{const Def}
	"int"					{const IntType}
	"boolean"				{const BoolType}
	"return"				{const Return}
	"{"					{const OpenBrace}
	"}"					{const CloseBrace}
	$alpha [$digit $alpha _ \? \!]*  	{Identificator}
	$digit+					{Integer . read}
{

data Token = Newline |
	Integer Integer |
	Identificator String |
	Plus   		| 
	Minus  		|
	Times  		|
	Divide 		|	
	Rem 		|	
	Do     		|
	Then   		|
	End    		|
	If     		|
	While  		|
	Semicolon 	|
	Colon	 	|
	Coma	 	|
	OpenParenth 	|
	CloseParenth 	|
	OpenBrace 	|
	CloseBrace 	|
	Asign 		|
	Equal 		|
	NotEqual 	|
	Less 		|
	Greater 	| 
	LessEqual	|
	GreaterEqual	|
	Var		|
	Def             |
	IntType		|
	BoolType	|
	Return
	deriving (Eq,Show)

lexer::String->[Token]
lexer = alexScanTokens 
}